SearchView

(SESL variant) A widget that provides a user interface for the user to enter a search query and submit a request to a search provider. Shows a list of query suggestions or results, if available, and allows the user to pick a suggestion or result to launch into.

When the SearchView is used in an ActionBar as an action view, it's collapsed by default, so you must provide an icon for the action.

If you want the search field to always be visible, then call setIconifiedByDefault(false).

See also

Constructors

Link copied to clipboard
constructor(@NonNull context: @NonNull Context)
constructor(@NonNull context: @NonNull Context, @Nullable attrs: @Nullable AttributeSet)
constructor(@NonNull context: @NonNull Context, @Nullable attrs: @Nullable AttributeSet, defStyleAttr: Int)

Types

Link copied to clipboard
interface OnCloseListener
Link copied to clipboard
Link copied to clipboard
Callbacks for changes to the query text.
Link copied to clipboard
Callback interface for selection events on suggestions.
Link copied to clipboard
Local subclass for AutoCompleteTextView.

Functions

Link copied to clipboard
open fun clearFocus()
Link copied to clipboard
open fun getImeOptions(): Int
Returns the IME options set on the query text field.
Link copied to clipboard
open fun getInputType(): Int
Returns the input type set on the query text field.
Link copied to clipboard
open fun getMaxWidth(): Int
Gets the specified maximum width in pixels, if set.
Link copied to clipboard
Returns the query string currently in the text field.
Link copied to clipboard
@Nullable
open fun getQueryHint(): @Nullable CharSequence
Returns the hint text that will be displayed in the query text field.
Link copied to clipboard
Returns the adapter used for suggestions, if any.
Link copied to clipboard
Returns the default iconified state of the search field.
Link copied to clipboard
open fun isIconified(): Boolean
Returns the current iconified state of the SearchView.
Link copied to clipboard
Returns whether query refinement is enabled for all items or only specific ones.
Link copied to clipboard
Returns whether the submit button is enabled when necessary or never displayed.
Link copied to clipboard
Called when this view is collapsed as an action view.
Link copied to clipboard
Called when this view is expanded as an action view.
Link copied to clipboard
open fun onWindowFocusChanged(hasWindowFocus: Boolean)
Link copied to clipboard
Link copied to clipboard
open fun requestFocus(direction: Int, previouslyFocusedRect: Rect): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun seslSetSviEnabled(enabled: Boolean): Boolean
Link copied to clipboard
open fun seslSetUpButtonIcon(drawable: Drawable)
Link copied to clipboard
open fun seslSetUpButtonVisibility(visibility: Int)
Link copied to clipboard
open fun setAppSearchData(appSearchData: Bundle)
Sets the APP_DATA for legacy SearchDialog use.
Link copied to clipboard
open fun setBackground(background: Drawable)
Link copied to clipboard
open fun setBackgroundResource(resid: Int)
Link copied to clipboard
open fun setElevation(elevation: Float)
Link copied to clipboard
open fun setIconified(iconify: Boolean)
Iconifies or expands the SearchView.
Link copied to clipboard
open fun setIconifiedByDefault(iconified: Boolean)
Sets the default or resting state of the search field.
Link copied to clipboard
open fun setImeOptions(imeOptions: Int)
Sets the IME options on the query text field.
Link copied to clipboard
open fun setInputType(inputType: Int)
Sets the input type on the query text field.
Link copied to clipboard
open fun setMaxWidth(maxpixels: Int)
Makes the view at most this many pixels wide maxWidth
Link copied to clipboard
Sets a listener to inform when the user closes the SearchView.
Link copied to clipboard
Sets a listener to inform when the focus of the query text field changes.
Link copied to clipboard
Sets a listener for user actions within the SearchView.
Link copied to clipboard
Sets a listener to inform when the search button is pressed.
Link copied to clipboard
Sets a listener to inform when a suggestion is focused or clicked.
Link copied to clipboard
open fun setQuery(query: CharSequence, submit: Boolean)
Sets a query string in the text field and optionally submits the query as well.
Link copied to clipboard
open fun setQueryHint(@Nullable hint: @Nullable CharSequence)
Sets the hint text to display in the query text field.
Link copied to clipboard
Specifies if a query refinement button should be displayed alongside each suggestion or if it should depend on the flags set in the individual items retrieved from the suggestions provider.
Link copied to clipboard
open fun setSearchableInfo(searchable: SearchableInfo)
Sets the SearchableInfo for this SearchView.
Link copied to clipboard
open fun setSubmitButtonEnabled(enabled: Boolean)
Enables showing a submit button when the query is non-empty.
Link copied to clipboard
You can set a custom adapter if you wish.